<?php /*a:2:{s:78:"C:\WebProject\nanxun-wechat-cms\application\admin\view\user\adminUserList.html";i:1552613133;s:77:"C:\WebProject\nanxun-wechat-cms\application\admin\view\layout\scriptload.html";i:1552554969;}*/ ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="stylesheet" href="/../static/bower_components/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="/../static/bower_components/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="/../static/bower_components/Ionicons/css/ionicons.min.css">
<link rel="stylesheet" href="/../static/dist/css/AdminLTE.min.css">
<link rel="stylesheet" href="/../static/dist/css/skins/_all-skins.min.css">
<link rel="stylesheet" href="/../static/bower_components/morris.js/morris.css">
<link rel="stylesheet" href="/../static/bower_components/jvectormap/jquery-jvectormap.css">
<link rel="stylesheet" href="/../static/bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
<link rel="stylesheet" href="/../static/bower_components/bootstrap-daterangepicker/daterangepicker.css">
<link rel="stylesheet" href="/../static/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
<link rel="stylesheet" href="/../static/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
<link rel="stylesheet" href="/../static/bower_components/select2/dist/css/select2.min.css">
<link rel="stylesheet" href="/../static/bower_components/bootstrap-daterangepicker/daterangepicker.css">
<link rel="stylesheet" href="/../static/bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
<link rel="stylesheet" href="/../static/plugins/timepicker/bootstrap-timepicker.min.css">
<script src="/../static/bower_components/jquery/dist/jquery.min.js"></script>
<script src="/../static/bower_components/jquery-ui/jquery-ui.min.js"></script>
<script src="/../static/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="/../static/bower_components/raphael/raphael.min.js"></script>
<script src="/../static/bower_components/morris.js/morris.min.js"></script>
<script src="/../static/bower_components/jquery-sparkline/dist/jquery.sparkline.min.js"></script>
<script src="/../static/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="/../static/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<script src="/../static/bower_components/jquery-knob/dist/jquery.knob.min.js"></script>
<script src="/../static/bower_components/moment/min/moment.min.js"></script>
<script src="/../static/bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
<script src="/../static/bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
<script src="/../static/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<script src="/../static/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<script src="/../static/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="/../static/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<script src="/../static/bower_components/fastclick/lib/fastclick.js"></script>
<script src="/../static/dist/js/adminlte.min.js"></script>
<script src="/../static/bower_components/select2/dist/js/select2.full.min.js"></script>
<script src="/../static/bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
<script src="/../static/bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
<script src="/../static/plugins/timepicker/bootstrap-timepicker.min.js"></script>
<script src="/../static/plugins/iCheck/icheck.min.js"></script>
<link rel="stylesheet" href="/../static/plugins/iCheck/all.css">
<!--引入layui-->
<link rel="stylesheet" href="/../static/layui/css/layui.css">
<script src="/../static/layui/layui.js"></script>
<script src="/../static/tencent/tencent.js"></script>
<script src="/../static/layui/commjslib-v2.0.1.js"></script>
<script src="/../static/layui/city-picker/city-picker.data.js"></script>
<link href="/../static/layui/city-picker/city-picker.css" rel="stylesheet" />
<!--引入vue-->
<script src="https://cdn.staticfile.org/vue/2.5.17/vue.js"></script>
<!--<script src="https://cdn.staticfile.org/vue/2.5.17/vue.min.js"></script>-->
<!--引入饿了么组件element-->
<link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.4.11/theme-chalk/index.css">
<script src="https://cdn.staticfile.org/element-ui/2.4.11/index.js"></script>
<!--引入图片上传-->
<link rel="stylesheet" href="/../static/html5upload/control/css/zyUpload.css" type="text/css">
<script src="/../static/html5upload/core/zyFile.js"></script>
<script src="/../static/html5upload/control/js/zyUpload.js"></script>
<script src="/../static/html5upload/core/jq22.js"></script>
<script>
    $.widget.bridge('uibutton', $.ui.button);
</script>
    <title>管理员列表</title>
</head>
<body>
<div class="box">
    <section class="content-header">
        <ol class="breadcrumb">
            <li><a><i class="fa fa-dashboard"></i> 管理员管理</a></li>
            <li class="active">管理员列表</li>
        </ol>
    </section>
    <!-- /.box-header -->
    <section class="content">
        <div class="box-body">
            <div id="example1_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
                <div class="row">
                    <div class="col-sm-12">
                        <div id="example1_filter" class="dataTables_length">
                            <label>搜索管理员：
                                <input type="search" id="keyword" class="form-control input-sm" placeholder="名称丶部门"
                                       aria-controls="example1">
                            </label>
                            <button type="button" id="search" class="btn margin"
                                    style="background: #18bc9c;color: #ffffff;">搜索
                            </button>
                            <button type="button" onclick="relist()" title="刷新" class="btn bg-aqua margin"><i
                                    class="fa fa-refresh"></i></button>
                            <button onclick="toadd()" class="btn margin" style="background: #18bc9c;color: #ffffff;">
                                添加管理员
                            </button>
                            <button type="button" onclick="todelete()" class="btn bg-red margin"><i
                                    class="fa  fa-trash-o"></i> 删除
                            </button>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12">
                        <table id="example1" class="table table-bordered table-striped dataTable" role="grid"
                               aria-describedby="example1_info">
                            <thead>
                            <tr role="row">
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    style="width: 60px;">
                                    <input id="allchecked" type="checkbox" style="margin-left: 10px">
                                </th>
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    style="width: 90px;">管理员头像
                                </th>
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    style="width: 190px;">管理员名称
                                </th>
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    style="width: 120px;">所属部分
                                </th>
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    style="width: 120px;">添加时间
                                </th>
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    style="width: 400px;">拥有角色
                                </th>
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    style="width: 100px;">角色修改
                                </th>
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    style="width: 120px;">操作
                                </th>
                            </tr>
                            </thead>
                            <tbody id="tb">
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <!-- /.box-body -->
    </section>
</div>
</body>
<script>
    var _keyword = '';
    $(function () {
        getlist(_keyword);
        $('#search').click(function () {
            table.destroy();
            var keyword = $('#keyword').val();
            getlist(keyword);
        })
        //反选
        $('#allchecked').click(function () {
            $("[name = checkboxed]:checkbox").each(function () {
                $(this).prop("checked", !$(this).prop("checked"));
            });
        });
    })

    function todelete() {
        var check_val = [];
        $('input[name="checkboxed"]:checked').each(function () {
            check_val.push($(this).val());
        });
        if (check_val == '') {
            layerAlert('请选择要删除的管理员');
            return false;
        }
        $.ajax({
            type: 'post',
            cache: false,
            url: '<?php echo url("admin/User/deleteUser"); ?>',
            data: {uid: check_val},
            success: function (data) {
                if (data.code == 0) {
                    layerAlert('删除成功', function () {
                        table.destroy();
                        getlist(_keyword);
                        layerParentClose();
                    });
                } else {
                    layerAlert('删除失败');
                    return false;
                }
            }
        })
    }

    function getlist(_keyword) {
        $.ajax({
            type: 'post', cache: false,
            url: '<?php echo url("admin/User/getUserList"); ?>',
            data: {keyword: _keyword},
            success: function (res) {
                if (res.msg === "ok") {
                    $("#tb tr").remove();
                    $.each(res.data, function (index, item) {
                        var html = '<tr role="row" class="odd" id="tr_' + item.id + '">';
                        html += '<td style="vertical-align: middle;"><input name="checkboxed" value="' + item.id + '" type="checkbox" style="margin-left: 10px"></td>';
                        html += '<td style="vertical-align: middle;"><img style="width: 60px;height: 60px;" src="' + item.pic + '" alt=""></td>';
                        html += '<td style="vertical-align: middle;">' + item.username + '</td>';
                        html += '<td style="vertical-align: middle;">' + item.department + '</td>';
                        html += '<td style="vertical-align: middle;">' + item.createtime + '</td>';
                        html += '<td style="vertical-align: middle;">' + item.roleid + '</td>';
                        html += '<td style="vertical-align: middle;">';
                        html += '<div class="btn-group" >';
                        html += ' <button onclick="toaddrole(' + item.id + ')" type="button" class="btn btn-block" style="background: #18bc9c;color: #ffffff;">修改角色</button>';
                        html += '</div>';
                        html += '</td>';
                        html += '<td style="vertical-align: middle;text-align: center">';
                        html += '<div class="btn-group">';
                        html += ' <button onclick="toedit(' + item.id + ')" type="button" class="btn btn-block" style="background: #18bc9c;color: #ffffff;"><i class="fa fa-edit"></i></button>';
                        html += '</div>';
                        html += '</td>';
                        html += '</tr>';
                        $("#tb").append(html);
                    });
                    table = $('#example1').DataTable({
                        "paging": true,
                        "lengthChange": false,
                        "lengthMenu": [[10], [10]],
                        "searching": false,
                        "ordering": false,
                        "info": true,
                        "language": {
                            "info": "展示第 <span style='color: red;'>_START_</span> 到 <span style='color: red;'>_END_</span> 个 共 <span style='color: red;'>_TOTAL_</span> 个公众号",
                            "paginate": {
                                "previous": "上一页",
                                "next": "下一页"
                            }
                        },
                        "autoWidth": true,
                    });
                }
            },
            error: function () {
                alert("发生系统错误,请与管理员联系！");
            }
        });
    }

    function toadd() {
        var url = '<?php echo url("User/addUser"); ?>'
        layerWindow('管理员管理->管理员列表->添加管理员', url, '25%', '60%');
    }

    function toaddrole(_id) {
        var url = '<?php echo url("User/addRoleList"); ?>?id=' + _id;
        layerWindow('管理员管理->管理员列表->添加角色', url, '25%', '60%');
    }

    function toedit(_id) {
        var url = '<?php echo url("User/editUser"); ?>?id=' + _id;
        layerWindow('管理员管理->管理员列表->修改管理员信息', url, '25%', '60%');
    }

    function relist() {
        table.destroy();
        getlist(_keyword);
    }
</script>
</html>